<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" import="java.util.*,com.pub.database.*" %>
<% response.setContentType("text/html;charset=UTF-8"); request.setCharacterEncoding("UTF-8"); %>
<% response.setHeader("Cache.Control","no-cache"); response.setHeader("Pragma","no-cache"); response.setDateHeader("Expires",0);%>
<jsp:useBean id="webFunction" scope="request" class="com.pub.web.WebFunction" />
<!-- 以下為DataView 共用設定 -->
<jsp:useBean id="DataViewForm" scope="request" class="com.pub.database.DataViewForm"/>
<jsp:setProperty name="DataViewForm" property="pageRowCount"  value="10"/>
<jsp:setProperty name="DataViewForm" property="nowPageNum"/>
<jsp:setProperty name="DataViewForm" property="submitMethod" value="POST"/>
<jsp:setProperty name="DataViewForm" property="dataViewAction"/>
<jsp:setProperty name="DataViewForm" property="filterCol"/>
<jsp:setProperty name="DataViewForm" property="filterValue"/>
<jsp:setProperty name="DataViewForm" property="dvOrderByFields"/>
<jsp:setProperty name="DataViewForm" property="dvOrderBySeq"/>
<!-- DataView 設定結束 -->
<%
String strFromSQL="";
String strWhereSQL="";
String stremployee_no="";
String stremployee_name="";
String stremployee_name_e="";
String strDataViewHtml=null;
DataView DataView=null;

try{
  DataViewForm.setFieldsList("'',pnl_employee.employee_no,pnl_employee.employee_name_c,pnl_employee.employee_name_e," +
  "(select max(employee_tel) from pnl_tel where employee_no=pnl_employee.employee_no),bas_dept.dept_no,bas_dept.dept_name");
  strFromSQL="pnl_employee,bas_dept";
  strWhereSQL=" pnl_employee.employee_st='A' and pnl_employee.dept_no=bas_dept.dept_no ";

  if(request.getParameter("myemployee_name")!=null && !request.getParameter("myemployee_name").trim().equals("")){
    stremployee_name=request.getParameter("myemployee_name").trim().toUpperCase();
    strWhereSQL+=" and employee_name_c like '" + stremployee_name + "%' ";
  }

  if(request.getParameter("myemployee_name_e")!=null && !request.getParameter("myemployee_name_e").trim().equals("")){
    stremployee_name_e=request.getParameter("myemployee_name_e").trim().toUpperCase();
    strWhereSQL+=" and Upper(employee_name_e) like '" + stremployee_name_e + "%' ";
  }

  if(request.getParameter("myemployee_no")!=null && !request.getParameter("myemployee_no").trim().equals("")){
    stremployee_no=request.getParameter("myemployee_no").trim().toUpperCase();
    strWhereSQL+=" and employee_no like '" + stremployee_no + "%' ";
  }

  DataViewForm.setTablesList(strFromSQL);
  DataViewForm.setSQLCondition(strWhereSQL);
  DataViewForm.setOrderByFields("employee_no");
  DataViewForm.setCountSQL("select count(employee_no) from " + strFromSQL + " where " + strWhereSQL);
  DataViewForm.setPageActionURI("find_employee.jsp?myemployee_name=" + stremployee_name +
  "&myemployee_no=" + stremployee_no +
  "&myemployee_name_e=" + stremployee_name_e +
  "&DB_ALIAS=" + request.getParameter("DB_ALIAS") +
  "&DEBUG=" + request.getParameter("DEBUG") +
  "&SOURCE_CHARSET=" + request.getParameter("SOURCE_CHARSET") +
  "&TARGET_CHARSET=" + request.getParameter("TARGET_CHARSET"));

  boolean blnDebug=false;
  String strColRelation[][]=new String[7][];

  strColRelation[0]=new String[5];
  strColRelation[1]=new String[5];
  strColRelation[2]=new String[5];
  strColRelation[3]=new String[5];
  strColRelation[4]=new String[5];
  strColRelation[5]=new String[5];
  strColRelation[6]=new String[5];

  strColRelation[0][0]="'SEL'";
  strColRelation[0][1]="INPUT";
  strColRelation[0][2]="WIDTH='5%'";
  strColRelation[0][3]="<input type='radio' CLASS='button b_normal' name='sel'  onclick=\"javascript:retVal(%sn%);\" value=";
  strColRelation[0][4]="0";

  strColRelation[1][0]="'工號'";
  strColRelation[1][1]="INPUT";
  strColRelation[1][2]="WIDTH='10%'";
  strColRelation[1][3]="<input type='input' name='employee_no%sn%' size='8' readonly class='input_noborder' value=";
  strColRelation[1][4]="1";

  strColRelation[2][0]="'中文姓名'";
  strColRelation[2][1]="INPUT";
  strColRelation[2][2]="WIDTH='15%'";
  strColRelation[2][3]="<input type='input' name='employee_name_c%sn%' size='10' readonly class='input_noborder' value=";
  strColRelation[2][4]="2";

  strColRelation[3][0]="'英文姓名'";
  strColRelation[3][1]="INPUT";
  strColRelation[3][2]="WIDTH='20%'";
  strColRelation[3][3]="<input type='input' name='employee_name_e%sn%' size='10' readonly class='input_noborder' value=";
  strColRelation[3][4]="3";

  strColRelation[4][0]="'分機'";
  strColRelation[4][1]="INPUT";
  strColRelation[4][2]="WIDTH='10%'";
  strColRelation[4][3]="<input type='input' name='tel%sn%' size='4' readonly class='input_noborder' value=";
  strColRelation[4][4]="4";

  strColRelation[5][0]="'部門代碼'";
  strColRelation[5][1]="INPUT";
  strColRelation[5][2]="WIDTH='10%'";
  strColRelation[5][3]="<input type='input' name='dept_no%sn%' size='8' readonly class='input_noborder' value=";
  strColRelation[5][4]="5";

  strColRelation[6][0]="'部門名稱'";
  strColRelation[6][1]="INPUT";
  strColRelation[6][2]="WIDTH='10%'";
  strColRelation[6][3]="<input type='input' name='dept_name%sn%' size='10' readonly class='input_noborder' value=";
  strColRelation[6][4]="6";

  DataViewForm.setColRelation(strColRelation);
  DataViewForm.setPageBtnOnTop(true);
  DataViewForm.setPageBtnOnButtom(false);
  DataViewForm.setFilterShow(false);
  DataViewForm.setJumpPageShow(true);
  DataViewForm.setRowsInfoShow(true);
  DataViewForm.setRowPageShow(false);
  DataViewForm.setExcelShow(false);
  DataViewForm.setOrderEnable(false);
  DataViewForm.setTableDataTrHtml("onmouseover=\"this.className='td_content_ov" +
  "er'\" onmouseout=\"this.className='td_content'\"");//設定每筆TR的Html
  DataViewForm.setTableHeaderHtml("class='td_head_grid' align='center'");

  DataView=new DataView(request.getParameter("DB_ALIAS"),
                       Boolean.valueOf(request.getParameter("DEBUG")).booleanValue(),
                       request.getParameter("SOURCE_CHARSET"),
                       request.getParameter("TARGET_CHARSET"));

  strDataViewHtml=DataView.getOutputDataView(DataViewForm);
}
catch(Exception e){
  e.printStackTrace();
}finally{
  DataViewForm.setColRelation(null);
  DataViewForm=null;
  DataView=null;
}
%>
<html>

<head>
<script language="javascript" type="">
      // Return values when exit  value: Part No , Description
      function retVal(v_sn){
         window.returnValue=document.all.item('employee_no' + v_sn).value + "," +
                            document.all.item('employee_name_c' + v_sn).value + "," +
                            document.all.item('employee_name_e' + v_sn).value + "," +
                            document.all.item('dept_no' + v_sn).value + "," +
                            document.all.item('dept_name' + v_sn).value + "," + ",,,," +
                            document.all.item('tel' + v_sn).value;
         window.close();
      }
</script>

<title>人員查詢</title>
<LINK HREF="general/workflow.css" REL="stylesheet" TYPE="text/css"/>
<base target='_self'/>
</head>
<body>

  <form action="find_employee.jsp" method="POST">
    <table>
      <tr>
         <th>工號：</th>
         <td><input type="text" name="myemployee_no" size="30" maxlength="30" class="input" value="<%=stremployee_no%>" />　</td>
         <td rowspan="3"><input type="submit"  value="尋找" />　</td>
      </tr>
      <tr>
         <th>中文姓名：</th>
         <td><input type="text" name="myemployee_name" size="30" maxlength="30" class="input" value="<%=stremployee_name%>" />　</td>
      </tr>
      <tr>
         <th>英文姓名：</th>
         <td><input type="text" name="myemployee_name_e" size="30" maxlength="30" class="input" value="<%=stremployee_name_e%>" />　</td>
      </tr>

    </table>
    <input type="hidden" name="DB_ALIAS" value="<%=request.getParameter("DB_ALIAS")%>" />
    <input type="hidden" name="DEBUG" value="<%=request.getParameter("DEBUG")%>" />
    <input type="hidden" name="SOURCE_CHARSET" value="<%=request.getParameter("SOURCE_CHARSET")%>" />
    <input type="hidden" name="TARGET_CHARSET" value="<%=request.getParameter("TARGET_CHARSET")%>" />
  </form>
  <%=strDataViewHtml==null?"":strDataViewHtml%>
</body>
</html>

